package com.sangfor.ssl.service.line;

import android.os.AsyncTask;
import com.sangfor.bugreport.logger.Log;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/* loaded from: classes2.dex */
public class DNSTask extends AsyncTask<Void, Void, Boolean> {
    private static final String TAG = "DNSTask";
    private DNSCallback mCallback;
    private Collection<String> mDomains;
    private InetAddress mInetAddress = null;
    private List<String> mAddresses = new ArrayList();

    /* loaded from: classes2.dex */
    public interface DNSCallback {
        void doAfterDNSTask(boolean z, List<String> list);
    }

    public DNSTask(Collection<String> collection, DNSCallback dNSCallback) {
        this.mCallback = null;
        this.mDomains = collection;
        this.mCallback = dNSCallback;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.os.AsyncTask
    public Boolean doInBackground(Void... voidArr) {
        try {
            for (String str : this.mDomains) {
                InetAddress byName = InetAddress.getByName(str);
                this.mInetAddress = byName;
                if (byName != null) {
                    this.mAddresses.add(byName.getHostAddress());
                }
            }
            return true;
        } catch (UnknownHostException e) {
            Log.error(TAG, "Unknown Host. ", e);
            return false;
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // android.os.AsyncTask
    public void onPostExecute(Boolean bool) {
        List<String> list;
        super.onPostExecute((DNSTask) bool);
        Log.info(TAG, "DNS parse over, result is:" + this.mInetAddress);
        if (!bool.booleanValue() || this.mInetAddress == null || (list = this.mAddresses) == null) {
            this.mCallback.doAfterDNSTask(false, null);
        } else {
            this.mCallback.doAfterDNSTask(true, list);
        }
    }
}
